﻿using Forum.Model.Enum;
using SqlSugar;

namespace Forum.Model.Entity
{
    /// <summary>
    /// 博客文章
    /// </summary>
    public class Post
    {
        [SugarColumn(IsPrimaryKey = true, IsIdentity = false)]
        public string Id { get; set; }
        /// <summary>
        /// 标题
        /// </summary>
        public string Title { get; set; }
        /// <summary>
        /// 文章状态，提取原markdown文件的文件名前缀，用于区分文章状态，例子如下
        /// <para>《（未完成）StarBlog博客开发笔记(3)：模型设计》</para>
        /// <para>《（未发布）StarBlog博客开发笔记(3)：模型设计》</para>
        /// </summary>
        public int Status { get; set; } = (int)PublishStatus.草稿;

        [Navigate(NavigateType.OneToOne, nameof(Status))]
        public SysParameters StatusOption { get; set; }
        /// <summary>
        /// 是否发表（不发表的话就是草稿状态）
        /// </summary>
        public bool IsPublish { get; set; }
        /// <summary>
        /// 梗概
        /// </summary>
        public string Summary { get; set; }
        /// <summary>
        /// 内容（markdown格式）
        /// </summary>
        public string Content { get; set; }
        [SugarColumn(IsIgnore = true)]
        public string ContentHtml { get; set; }
        /// <summary>
        /// 博客在导入前的相对路径
        /// <para>如："系列/AspNetCore开发笔记"</para>
        /// </summary>
        public string Path { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreationTime { get; set; }
        /// <summary>
        /// 上次更新时间
        /// </summary>
        public DateTime LastUpdateTime { get; set; }
        /// <summary>
        /// 分类ID
        /// </summary>
        public int CategoryId { get; set; }

        [Navigate(NavigateType.OneToOne, nameof(CategoryId))]
        public Category Category { get; set; }
        /// <summary>
        /// 发布时间
        /// </summary>
        public DateTime? PublishTime { get; set; }
        /// <summary>
        /// 缩略图
        /// </summary>
        public string Banner { get; set; } = "http://180.76.128.139:5002/media/banner/banner.jpg";
        /// <summary>
        /// 是否置顶
        /// </summary>
        public bool IsTop { get; set; }
        /// <summary>
        /// 是否推荐文章
        /// </summary>
        public bool IsRecommend { get; set; }
        /// <summary>
        /// 评论数
        /// </summary>
        public int CommentsCount { get; set; } = 0;
        /// <summary>
        /// 浏览量
        /// </summary>
        public int ViewsCount { get; set; } = 0;
    }
}